#include<iostream>
#include<queue>
#include <vector>


using namespace std;




class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};


vector<vector<int>> levelOrder(Node* root) {
    queue<Node*> qt;
    qt.push(root);
    int n = qt.size();
    vector<vector<int>> ret;
    while (!qt.empty())
    {
        vector<int> v;
        while (n--)
        {
            Node* tmp = qt.front();
            v.push_back(tmp->val);
            for (auto data : tmp->children)
            {
                qt.push(data);
            }
        }

        n = qt.size();
        ret.push_back(v);
    }


    return ret;
}

int main()
{
    Node root(1);
    
    root.children.push_back(Node(3)); 
    

    root.val;

    return 0;
}





/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
public:
    vector<vector<int>> levelOrder(Node* root) {
        vector<vector<int>> ret;
        if (root == nullptr) return ret;
        queue<Node*> qt;
        qt.push(root);
        int n = qt.size();


        while (!qt.empty())
        {
            vector<int> v;
            while (n--)
            {
                Node* tmp = qt.front();
                qt.pop();
                v.push_back(tmp->val);
                for (auto data : tmp->children)
                {
                    if (data != nullptr)
                        qt.push(data);
                }
            }

            n = qt.size();
            ret.push_back(v);
        }


        return ret;
    }
};